<template>
  <Loading v-model:visible="visible" />
</template>

<script setup>
import { ref, onMounted } from 'vue'
import Loading from './index.vue'
import { setLoadingInstance } from '@/utils/loading.js'

const visible = ref(false)

// 提供给外部调用的方法
const setVisible = (value) => {
  visible.value = value
}

const toggle = () => {
  visible.value = !visible.value
}

// 向全局管理器中注册方法
onMounted(() => {
  setLoadingInstance({ setVisible, toggle })
})
</script>

